package com.jlastu.znb.entity;

import java.util.ArrayList;
import java.util.List;

public class News {
    private int id;              // 新闻唯一标识
    private String title;        // 新闻标题
    private String subtitle;     // 新闻副标题，可能为空
    private String date;         // 发布日期
    private String content;      // 新闻正文
    private List<NewsPhoto> photoList; // 相关图片列表
    private String category; // 货品分类属性    // 其他可能的属性，如作者、来源等

    private String detailUrl; // 新增属性
    // 其他属性和方法...
    public String getDetailUrl() {
        return detailUrl;
    }
    public void setDetailUrl(String detailUrl) {
        this.detailUrl = detailUrl;
    }
    // 省略其他getter和setter
    // 构造函数
    public News(int id, String title, String subtitle, String date, String content) {
        this.id = id;
        this.title = title;
        this.subtitle = subtitle;
        this.date = date;
        this.content = content;
    }

    public News() {

    }

    // Getter 和 Setter 方法
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getSubtitle() {
        return subtitle;
    }

    public void setSubtitle(String subtitle) {
        this.subtitle = subtitle;
    }

    public String getDate() {
        return date;
    }

    public void setDate(String date) {
        this.date = date;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public List<NewsPhoto> getPhotoList() {
        return photoList;
    }

    public void setPhotoList(List<NewsPhoto> photoList) {
        this.photoList = photoList;
    }
    public String getCategory() {
        return category;
    }

    public void setCategory(String category) {
        this.category = category;
    }

    // 可以添加方法来添加图片到列表
    public void addPhoto(NewsPhoto newsphoto) {
        if (this.photoList == null) {
            this.photoList = new ArrayList<>();
        }
        this.photoList.add(newsphoto);
    }

    // 重写 toString 方法，便于调试时输出 News 对象信息
    @Override
    public String toString() {
        return "News{" +
                "id=" + id +
                ", title='" + title + '\'' +
                ", subtitle='" + subtitle + '\'' +
                ", date='" + date + '\'' +
                ", content='" + content + '\'' +
                ", category='" + category + '\'' + // 添加货品分类到toString方法
                // 根据需要添加其他属性
                '}';
    }

    public void setPhotos(List<NewsPhoto> photos) {
    }
}